#include <iostream>
#include <string>
#include <vector>
#include "week01/c01-lc26.h"
#include "week01/c02-lc150.h"
#include "week01/c02-lc227.h"
#include "week01/w01-homework.h"
#include "week02/c03-lc49.h"
#include "week02/c03-lc30.h"
#include "week02/c03-lc146.h"
#include "week02/c04-lc22.h"
#include "week03/c05-lc-tree-diameter.h"

using namespace std;

void testLeetCodeTreeDiameter(){
    LeetCodeTreeDiameter lctd;
    vector<vector<int>> edges1 = {{0,1},{0,2}};
    vector<vector<int>> edges2 = {{0,1},{1,2},{2,3},{1,4},{4,5}};
    int ans = lctd.treeDiameter(edges2);
    cout << ans << endl;
}

void testLeetCode22() {
    LeetCode22 lc22;
    vector<string> ans = lc22.generateParenthesis(3);
    cout << "[";
    for (string &a: ans)
        cout << a << ",";
    cout << "]" << endl;
}

void testLeetCode146() {
    LeetCode146 lRUCache(2);
    lRUCache.put(1, 1); // 缓存是 {1=1}
    lRUCache.put(2, 2); // 缓存是 {1=1, 2=2}
    lRUCache.get(1);    // 返回 1
    lRUCache.put(3, 3); // 该操作会使得关键字 2 作废，缓存是 {1=1, 3=3}
    lRUCache.get(2);    // 返回 -1 (未找到)
    lRUCache.put(4, 4); // 该操作会使得关键字 1 作废，缓存是 {4=4, 3=3}
    lRUCache.get(1);    // 返回 -1 (未找到)
    lRUCache.get(3);    // 返回 3
    lRUCache.get(4);    // 返回 4

}

void testLeetCode30() {
    vector<string> words = {"bar", "foo", "the"};
    string s = "barfoofoobarthefoobarman";
    LeetCode30 lc30;
    vector<int> ans = lc30.findSubstring(s, words);
    cout << "[";
    for (int n: ans) {
        cout << n << ", ";
    }
    cout << "]" << endl;

}

void TestLeetCode49() {
    vector<string> input = {"eat", "tea", "tan", "ate", "nat", "bat"};
    LeetCode49 lc49;
    vector<vector<string>> output = lc49.groupAnagrams(input);
    cout << "[ ";
    for (vector<string> o: output) {
        cout << "[";
        for (string s: o) {
            cout << s << ",";
        }
        cout << "]";
    }
    cout << " ]" << endl;

}

void TestLeetCode150() {
    LeetCode150 lc150;
    vector<string> tokens = {"4", "13", "5", "/", "+"};
    int z = lc150.evalRPN(tokens);
    cout << "TestLeetCode150:[" << z << "]" << endl;
}

void TestLeetCode227() {
    string string1 = "3+2*2";
    LeetCode227 lc227;
    cout << lc227.calculate(string1) << endl;
}


int main() {
    testLeetCodeTreeDiameter();
    /*
    testLeetCode30();
    TestLeetCode49();

    Week01HomeWork homeWork;
    homeWork.test01();
    TestLeetCode227();
    TestLeetCode150();
    std::cout << "Hello, World!" << std::endl;
     */
    return 0;
}
